package com.example.mybaiduweishi.fragments;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.mybaiduweishi.MyApplication;
import com.example.mybaiduweishi.R;
import com.example.mybaiduweishi.fragments.base.BaseFragmentbase;
import com.example.mybaiduweishi.vo.Contacts;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/6/7 0007.
 */

public class SelectContactFragment extends BaseFragmentbase {
    @BindView(R.id.rv_select_contact)
    RecyclerView rvSelectContact;
    //    @BindView(R.id.rv_select_contact)
//    RecyclerView rvSelectContact;
    List<Contacts> contactsList = new ArrayList<Contacts>();
    ShowContactsFragment.MyContactsAdapter contactsAdapter;
    @Override
    public int getXML() {
        return R.layout.select_contact_fragment;
    }

    @Override
    public void initView() {
        List<Contacts> alllist = MyApplication.getList();
        //获取输入框中的内容
        for (int i = 0; i < alllist.size(); i ++){

        }
        //getActivity（）找寻这个碎片的宿主
//        ShowContactsFragment.MyContactsAdapter adapter = new ShowContactsFragment.MyContactsAdapter()
        rvSelectContact.setLayoutManager(new LinearLayoutManager(getActivity()));
    }

    @Override
    public void initData() {
//        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
//        ShowContactsFragment.MyContactsAdapter adapter = new ShowContactsFragment.MyContactsAdapter(contactsList);
//        rvSelectContact.setAdapter(adapter);
        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
        contactsAdapter = new ShowContactsFragment.MyContactsAdapter(contactsList);
        rvSelectContact.setAdapter(contactsAdapter);
    }

    public  void getSelectContactList(List<Contacts> list){
        contactsList.clear();
        contactsList.addAll(list);
        if (contactsAdapter!=null) {
            contactsAdapter.notifyDataSetChanged();
        }
    }


}
